<template>

  <el-header>
    <div class="l-content">
      <!-- 图标 -->
      <el-button @click="handleCollapse()" size="small">
        <el-icon>
          <Menu />
        </el-icon>
      </el-button>
      <!-- 面包屑 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="current.path" v-if="current" >{{ current.label }}</el-breadcrumb-item>
      </el-breadcrumb>

    </div>
    <div class="r-content">
      <el-dropdown>
        <span class="el-dropdown-link">
          <img class="user" :src="getImgSrc('user')" alt="">
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>Action 1</el-dropdown-item>
            <el-dropdown-item>Action 2</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </el-header>

</template>

<script setup>
import { computed } from 'vue';
// 引入仓库
import { useAside } from '@/store/index.js';
const main = useAside()

const getImgSrc = (val) => {
  // console.log(import.meta.url);
  // console.log(new URL(`../assets/${val}.jpg`, import.meta.url));
  return new URL(`../assets/${val}.jpg`, import.meta.url).href
}

const current =computed(()=>{
  return main.currentMenu
})


const handleCollapse = () => {
  main.updateIsCollapse()
}

</script>


<style lang="less">
header {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  background-color: #333;
}

.r-content {
  .user {
    width: 30px;
    height: 30px;
    border-radius: 50%;
  }
}

.l-content {
  display: flex;
  justify-content: center;
  align-items: center;

  .el-button {
    margin-right: 20px;
  }


  .el-breadcrumb__inner.is-link {
    color: #fff;

  }
  .el-breadcrumb__inner a:hover, .el-breadcrumb__inner.is-link:hover {
    color: rgb(121.3, 187.1, 255);
    cursor: pointer;
}
}
</style>